// readonly
class Person15_1 {
  public readonly name: string;
  constructor(name: string) {
    this.name = name;
  }
}

const person15_1 = new Person15_1("Dell");
// 因为 name 属性是 readonly 格式，所以修改会报错
person15_1.name = "hello";
console.log(person15_1.name);

// 抽象类，只能被继承，不能直接实例化
abstract class Geom {
  width: number;
  getType() {
    return "Gemo";
  }
  // 抽象方法，不写具体的实现，由每个具体的实体类自己去写，而且是必须要有这个方法，否则会报错
  abstract getArea(): number;
}

class Circle extends Geom {
  getArea() {
    return 123;
  }
}
class Square {}
class Triangle {}

// 接口和抽象类有一点像，抽象类是把类里通用的东西抽离了出来
// 接口是把对象等其他的东西里通用的东西抽离了出来
interface Person15_2 {
  name: string;
}

interface Teacher extends Person15_2 {
  teachingAge: number;
}

interface Student extends Person15_2 {
  age: number;
}

interface Driver {
  name: string;
  age: number;
}

const teacher = {
  name: "dell",
  teachingAge: 3,
};

const student = {
  name: "lee",
  age: 18,
};

const getUserInfo = (user: Person15_2) => {
  console.log(user.name);
};

getUserInfo(teacher);
getUserInfo(student);
